package com.test01.controller;

import com.test01.bean.Student;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * author: xl
 * time: 2018/5/22 14:39
 * description:
 **/

@Controller
@RequestMapping("/user")
public class UserController {


    @RequestMapping(value = "/goReg2",method = RequestMethod.GET)
    public String goReg2(String pageName){
        return "reg/"+pageName;
    }

    @RequestMapping(params = "method=reg2")
    public ModelAndView reg2(String name){
         ModelAndView modelAndView = new ModelAndView();
        Student student=new Student();
        student.setAge(28);
        student.setId(1);
        student.setName(name);
        modelAndView.addObject("stu", student);
        modelAndView.setViewName("reg/result");
         return modelAndView;
    }

    @RequestMapping(value = "/goReg3",method = RequestMethod.GET)
    public String goReg3(String pageName, HttpServletRequest request, ModelMap modelMap){
        modelMap.put("name","xiaoli");
        request.getSession().setAttribute("c","ccc");
        return "reg/"+pageName;
    }




}
